package com.yjk.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yjk.entity.Student;
import com.yjk.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjk
 * @since 2022-03-08
 */
@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private IStudentService ss;
    @GetMapping("/selectAll")
    public List<Student> selectAll(){
        return ss.list();
    }
    @GetMapping("/selectByCid")
    public List<Student> selectByCid(int cid){
        QueryWrapper<Student> wrapper = new QueryWrapper<>();
        wrapper.eq("cid",cid);
        return ss.list(wrapper);
    }
    @PostMapping("/add")
    public void add(@RequestBody Student stu){
        ss.save(stu);
    }
    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") int id){
        ss.removeById(id);
    }

}

